/**
 * 文章接口
 */

import type { User, Article } from "@/type";

export type GetArticleListResult = {
    list: (Article & { user: Omit<User, 'password'> })[],
    page_size: number
    total: number
    seo_title: string,
    seo_description: string,
    seo_keywords: string
}

/**
 * 获取文章列表
 * @param data
 * @param data.page 页码
 * @param data.size 每页条数
 */
export function getArticleList(data: { page: number, size?: number, keywrod?: string, type?: string }) {
    return useRequest<GetArticleListResult>('/v1/article/getArticleList', {
        method: 'get',
        query: data,
    })
}

/**
 * 获取文章详情
 * @param id 文章id
 */
export function getArticleInfo(id: number) {
    return useRequest<{
        row: Article,
        row_last: Article | null,
        row_next: Article | null,
    }>(`/v1/article/getArticleInfo`, {
        method: 'get',
        query: {
            id
        }
    })
}